#pragma once
#include <cstddef>
#include <vector>
namespace lcir {
template <class NodeTy>
class GraphNode {
  std::vector<NodeTy *> prevs;
  std::vector<NodeTy *> succs;

 public:
  void addPrev(NodeTy *node) { prevs.push_back(node); }
  void addSucc(NodeTy *node) { succs.push_back(node); }
  std::vector<NodeTy *> getPrevs() const { return prevs; }
  std::vector<NodeTy *> getSuccs() const { return succs; }
  NodeTy *getPrev(size_t i) const { return prevs[i]; }
  NodeTy *getSucc(size_t i) const { return succs[i]; }
  /**
   * @brief 删除节点，这个效率很低，需要遍历，就先这样用吧
   */
  void removePrev(NodeTy *node) {
    for (auto it = prevs.begin(); it != prevs.end(); ++it) {
      if (*it == node) {
        prevs.erase(it);
        break;
      }
    }
  }
  void removeSucc(NodeTy *node) {
    for (auto it = succs.begin(); it != succs.end(); ++it) {
      if (*it == node) {
        succs.erase(it);
        break;
      }
    }
  }
};
}  // namespace lcir